package com.juc.forkJoin.forkJoin4;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

public class Test1 {

	public static void main(String[] args) {
		//使用get()方法执行任务时，当子任务出现异常时可以在main主线程进行捕获
		try {
			MyRecursiveTask task1 = new MyRecursiveTask();
			ForkJoinPool pool =new ForkJoinPool();
			ForkJoinTask<Integer> task2 = pool.submit(task1);
			System.out.println(task2.get());
			for (int i = 0; i < Integer.MAX_VALUE; i++) {
				String newString = new String();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
				Math.random();
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
			System.out.println("进入了 main A");
		} catch (ExecutionException e) {
			e.printStackTrace();
			System.out.println("进入了 main B");
		}
		System.out.println("main end !");
	}
}
